#ifndef XMLPARSER_H
#define XMLPARSER_H

#include <QObject>
#include <QDir>
#include <QDomElement>
#include <QDomNode>
#include <QFile>
#include <QDebug>

#ifdef _TTY_POSIX_
#include <sys/stat.h>
#include <dirent.h>
#endif

#include "log.h"


extern QString g_installPath;

typedef struct{
    QString proPath;
    QString publishTime;
    QString dbPath;
    QString resoucePath;
    qint64  resourceSize;
} ProjectStruct;

class XmlParser : public QObject
{
    Q_OBJECT

    LOG4QT_DECLARE_QCLASS_LOGGER

public:
    explicit XmlParser(QObject *parent = 0);

    void setParsetFile(const QString& xmlProPath);
    int  parserFile(const QString& xmlProPath, QString& publishTime, QString& dbPath, QString& resourcePath);

    ProjectStruct parsetProFile(const QString& xmlProPath);

private:
    QString xmlPath;

private:
    void parser(const QString& filePath);
    qint64 countDirSize(const QString& dirPath);

signals:
    //解析完成，err，错误情况；publishTime,发布情况；dbPath，数据数据；resourcePath，资源路径
    //err：-1,找不到路径；-2，xml文件格式错误；-3，rootName错误;-4,projectName错误
    void parserFinish(int err, const QString& proPath = 0, const QString& publishTime = 0, const QString& dbPath = 0, const QString& resourcePath = 0);



};

#endif // XMLPARSER_H
